//
//  BLTextView.m
//  新浪微博
//
//  Created by hbl on 16/3/1.
//  Copyright © 2016年 hbl. All rights reserved.
//

#import "BLTextView.h"
@interface BLTextView()
@property (nonatomic, weak)UILabel *placeholder;
@end
@implementation BLTextView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *placeholder = [[UILabel alloc]init];
        placeholder.text = @"分享新鲜事...";
        placeholder.textColor = [UIColor lightGrayColor];
        placeholder.frame = CGRectMake(8, 2, 350, 35);
        placeholder.font = [UIFont systemFontOfSize:19];
        [self addSubview:placeholder];
        self.placeholder = placeholder;
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onTextChange) name:UITextViewTextDidChangeNotification object:nil];
    }
    return self;
}

- (void)onTextChange
{
    self.placeholder.hidden = !(self.text.length == 0);
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
